/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 * Author: Huawei OS Kernel Lab
 * Create: Thu Aug 15 16:14:23 2023
 */

#ifndef __LIBLINUX_UNIMPL_H__
#define __LIBLINUX_UNIMPL_H__

#ifdef CONFIG_LIBLINUX
#ifndef __ASSEMBLY__

#include <linux/export.h>
#ifdef __KERNEL__
#include <linux/printk.h>
#define liblinux_unimpl_printf(fmt, ...) \
	pr_info_once(fmt, ##__VA_ARGS__)
#else
#include <stdio.h>
#define liblinux_unimpl_printf(fmt, ...) \
	fprintf(stderr, fmt, ##__VA_ARGS__)
#endif


#define LIBLINUX_UNIMPL(name) \
	void __attribute__((section(".__liblinux_unimpl"))) \
	name(void) { liblinux_unimpl_printf("UN-IMPL: %s\n", __func__); }

#define LIBLINUX_UNIMPL_RET(name, type, ret) \
	type __attribute__ ((section(".__liblinux_unimpl"))) \
	name(void) { liblinux_unimpl_printf("UN-IMPL: %s\n", __func__); return ret; }

#define LIBLINUX_EXPORTED_UNIMPL(name) \
	LIBLINUX_UNIMPL(name)   \
	EXPORT_SYMBOL(name)

#define LIBLINUX_EXPORTED_UNIMPL_RET(name, type, ret) \
	LIBLINUX_UNIMPL_RET(name, type, ret)    \
	EXPORT_SYMBOL(name)

#define LIBLINUX_GPL_EXPORTED_UNIMPL(name) \
	LIBLINUX_UNIMPL(name)   \
	EXPORT_SYMBOL_GPL(name)

#define LIBLINUX_GPL_EXPORTED_UNIMPL_RET(name, type, ret) \
	LIBLINUX_UNIMPL_RET(name, type, ret)    \
	EXPORT_SYMBOL_GPL(name)

#define EX_SYMBOL(name) \
	extern unsigned long name; \
	EXPORT_SYMBOL(name)

#endif  /* !__ASSEMBLY__ */
#endif  /* CONFIG_LIBLINUX */
#endif  /* __LIBLINUX_UNIMPL_H__*/
